package spike.postagger;

import java.io.IOException;
import java.sql.SQLException;
import java.util.ArrayList;

import aspect.AspectGenerator;

import db.QueryPool;

import edu.stanford.nlp.tagger.maxent.MaxentTagger;

public class XMLConverter {
	public static void main(String[] args) throws ClassNotFoundException, IOException, SQLException {
		XMLConverter xml = new XMLConverter();
		xml.aspectGenerator("here is my name baby! you are so beautiful");
	}
	
	public void aspectGenerator(String message) throws ClassNotFoundException, IOException, SQLException {
		MaxentTagger tagger = new MaxentTagger("models/left3words-wsj-0-18.tagger");
		String taggedString = tagger.tagString(message);
		QueryPool query = new QueryPool();
		
		String[] arrays = taggedString.split(" ");
		String aspect = "";
		for (int i = 0; i < arrays.length; i++) {
			if (arrays[i].indexOf("/NN") >= 0) {
				aspect = arrays[i].substring(0, arrays[i].indexOf("/NN"));
				if (query.existAspect(aspect)) {
					query.plusOneCountOfAspects(aspect);
				} else {
					query.addNewAspect(aspect);
				}
			}
		}
	}
	
	
}
